package com.ruoyi.project.syl_DZ.D.q.controller;

import java.util.List;

import com.ruoyi.project.syl_DZ.D.q.domain.OutpatientRegister2;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.syl_DZ.D.q.service.IOutpatientRegisterService2;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2021-07-17
 */
@RestController
@RequestMapping("/system/register2")
public class OutpatientRegisterController2 extends BaseController
{
    @Autowired
    private IOutpatientRegisterService2 outpatientRegisterService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:register2:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutpatientRegister2 outpatientRegister)
    {
        startPage();
        List<OutpatientRegister2> list = outpatientRegisterService.selectOutpatientRegisterList(outpatientRegister);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:register2:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OutpatientRegister2 outpatientRegister)
    {
        List<OutpatientRegister2> list = outpatientRegisterService.selectOutpatientRegisterList(outpatientRegister);
        ExcelUtil<OutpatientRegister2> util = new ExcelUtil<OutpatientRegister2>(OutpatientRegister2.class);
        return util.exportExcel(list, "register");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:register2:query')")
    @GetMapping(value = "/{registerSort}")
    public AjaxResult getInfo(@PathVariable("registerSort") Long registerSort)
    {
        return AjaxResult.success(outpatientRegisterService.selectOutpatientRegisterById(registerSort));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:register2:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutpatientRegister2 outpatientRegister)
    {
        return toAjax(outpatientRegisterService.insertOutpatientRegister(outpatientRegister));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:register2:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutpatientRegister2 outpatientRegister)
    {
        return toAjax(outpatientRegisterService.updateOutpatientRegister(outpatientRegister));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:register2:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registerSorts}")
    public AjaxResult remove(@PathVariable Long[] registerSorts)
    {
        return toAjax(outpatientRegisterService.deleteOutpatientRegisterByIds(registerSorts));
    }
}
